package com.wswy.wzcx.ui.persenter;

import android.content.Context;
import android.text.TextUtils;

import android.view.View;
import com.che.libcommon.recycler.OnItemClickedListener;
import com.che.libcommon.recycler.RowListAdapter;
import com.che.libcommon.utils.ToastUtils;
import com.wswy.wzcx.api.ConfigsKt;
import com.wswy.wzcx.model.DataCenter;
import com.wswy.wzcx.model.MyOrderMode;
import com.wswy.wzcx.ui.web.WebViewActivity;

/**
 * Created by wangduheng26 on 2018/3/14.
 * wangduheng26@gmail.com
 */

public class MyOrderPresenter {
    private Context context;

    public void onCreate(Context c) {
        context = c;
    }

    public void setupPage() {

    }

    public void onDestroy() {
        context = null;
    }

    public void setAdapterClick(RowListAdapter<MyOrderMode> adapter) {

        adapter.setOnItemClickedListener(new OnItemClickedListener<MyOrderMode>() {
            @Override
            public void onItemClicked(View view, MyOrderMode myOrderMode, int position) {
                if(DataCenter.get().hasLogin()){
                    String token= DataCenter.get().getUserMode().token;
                    String url = TextUtils.concat(ConfigsKt.H5_ORDER_DETAIL(), "orderNo=", myOrderMode.getOrderNo(), "&token=",token).toString();
                    WebViewActivity.startWebview(context, "订单详情", url, true);
                }
            }
        });

    }
}
